java | 您所在的位置:网站首页 › mybatis update返回值0 › java |
1.更新时返回值为0,影响行数为0。不知道为什么,自己尝试在数据库管理系统执行sql语句是有作用的。也不报错,求大神!2.代码如下: 1)Mapper.xml update cardown memberId = #{memberid,jdbcType=INTEGER}, cardId = #{cardid,jdbcType=INTEGER}, discount = #{discount,jdbcType=REAL}, balance = #{balance,jdbcType=REAL}, status = #{status,jdbcType=CHAR}, where cardOwnId = #{cardownid,jdbcType=INTEGER}2)Service(Dao层就省略了) @Override public int topUpToCard(CardOwn cardOwn) { // TODO Auto-generated method stub return cardOwnDao.updateByPrimaryKeySelective(cardOwn); }3)Controller内 CardOwn cardOwn = new CardOwn(); cardOwn.setCardid(cardOwnId); cardOwn.setBalance(balance+amount); int success = memberService.topUpToCard(cardOwn); if (success == 0) { System.out.println("充值失败"); }else { System.out.println("充值成功"); } |
CopyRight 2018-2019 实验室设备网 版权所有 |